using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public partial class MenuUI : UIWindowBase
{
    protected override void OnAwake()
    {
        base.OnAwake();

    }
    protected override void OnButtonClick(Button target)
    {
        base.OnButtonClick(target);
        if (target == this.open_Button)
        {
            GameEntry.GUI.Open(GameEntry.GUIPath.MainUI);
        }
        else if (target == this.unload_Button)
        {
            GameEntry.Table.Lang.Branch = GameEntry.Table.Lang.Branch == "en" ? "ch" : "en";
            GameEntry.Coroutine.Start(GameEntry.Table.LoadLang(GameEntry.AssetsLoader, () =>
            {
                TextLang.UpdateAll();
            }));
            // GameEntry.Entity.Add<Move>("Assets/Res/Prefabs/P" + (Random.Range(1, 3)) + ".prefab");
            // List<Worker> result = new List<Worker>();
            // GameEntry.Entity.GetEntitys<Worker>(result);
            // var len = Mathf.Min(result.Count, 10);
            // while (len-- > 0)
            // {
            //     GameEntry.Entity.Remove(result[len]);
            // }
        }
        else if (target == this.act2_Button)
        {
            // for (int i = 0; i < 10; i++)
            // {
            //     var worker = GameEntry.Entity.Add<Worker>("Assets/Res/Prefabs/Avatar/DogPolyart.prefab");
            //     worker.MoveTo(new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20)));
            // }
            Application.Quit();

        }
        else if (target == this.act3_Button)
        {
            if (GameEntry.Context.World.ActiveActor != null)
            {
                GameEntry.Context.World.ActiveActor.Ping();
            }
            return;
        }
    }
    protected override void OnFocus()
    {
        base.OnFocus();
        Debug.LogError("focus");
    }
}